import time

from selenium.webdriver.common.by import By

from pages.basePage import BasePage
from pages.ecShopLoginPages import Login
from pages.myinfoPage import MyInfoPage


class IndexPage(BasePage):
    # 属性登录、我的账号
    eloginOrUname = (By.XPATH,"//*[@id='ECS_MEMBERZONE']/a[1]")
    indaccot  = (By.XPATH,"//*[@class='header_r']/a[1]")
    # 方法进入登录、进入我的账号页面
    def go_to_myInfoPage(self):
        if self.getEleTxt(self.findEle(self.eloginOrUname)) == '登录':
            lp = self.go_to_loginPage()  # 进入登陆页面
            lp.denglu()
        time.sleep(3)
        ccot = self.findEle(self.indaccot)  # 点击我的账号（已登录）
        self.eleClick(ccot)
        time.sleep(3)
        return MyInfoPage(self.driver)
        #   进行登录操作
        # self.eleClick(self.findEle(self.dl))
        # self.eleClick(self.findEle(self.zh))

    def go_to_loginPage(self):
        # 点击登录按钮
        self.eleClick(self.findEle(self.eloginOrUname))
        # 得到登录页面对象
        lp = Login(self.driver)
        return  lp


if __name__ == '__main__':
    msgP=IndexPage().go_to_myInfoPage().go_to_myMSGPage()
    # lp=ip.go_to_loginPage()
    # lp.login()    #同时首页实现登录

    msgP.liuyan("biaottitle","neirrrr","sss")
    a1,a2=msgP.addMsg()
    print(a1,a2)
    #前置 准备

